package rabbit.flt.plugins.spring.r2dbc.low.matcher;

import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import rabbit.flt.plugins.common.matcher.SupportMatcher;

import static net.bytebuddy.matcher.ElementMatchers.named;

/**
 * DefaultDatabaseClient 类增强
 * 适用于版本低于1.2的
 */
public class DefaultDatabaseClientMatcher implements SupportMatcher {

    @Override
    public ElementMatcher.Junction<TypeDescription> classMatcher() {
        return named("org.springframework.data.r2dbc.core.DefaultDatabaseClient");
    }

    @Override
    public ElementMatcher.Junction methodMatcher(TypeDescription typeDescription) {
        return named("exchangeUpdate").or(named("exchangeInsert"));
    }

    @Override
    public String getPluginClassName() {
        return "rabbit.flt.plugins.spring.r2dbc.low.plugin.DefaultDatabaseClientPlugin";
    }
}
